package com.cj.mvvmlib.util

import android.os.CountDownTimer
import android.util.Log
import android.widget.TextView

class MyCountDownTimer(millisInFuture: Long, countDownInterval: Long,
                       var textView: TextView?, var finishCallback: (Unit) -> Unit) :
        CountDownTimer(millisInFuture, countDownInterval) {

    override fun onFinish() {
        finishCallback.invoke(Unit)
    }

    override fun onTick(millisUntilFinished: Long) {
        //单位秒

        //单位秒
        val second: Long = millisUntilFinished / 1000

        // 倒计时间隔回调

        // 倒计时间隔回调
        Log.d("TAG", String.format("剩余时间：%d秒", second))
        textView?.text = second.toString() + "s"
    }
}